<?php
class Uploader
{
    private $_files = array();
    private $_uploadDir = '';
    private $_allowedTypes = array(
        'image/jpeg',
        'image/png',
        'image/gif',
        'application/pdf'
    );
    private $_maxSize;
    
    public function __construct($files){
        $this->_files = $files;
    }

    protected function _validate($files){
        if(!in_array($files, $this->_allowedTypes))
            throw new Exception('invalid file');
        else
            return true;
    }

    public function getUploadDir(){
        return $this->_uploadDir;
    }

    public function setUploadDir($uploadDir){
        $this->_uploadDir = $uploadDir;
    }

    public function upload($uploadDir){
        foreach($this->_files['name'] as $i => $name){
            if($this->_validate($this->_files['type'][$i])){
                $filename = uniqid(time()).'.pdf';
                move_uploaded_file($this->_files['tmp_name'][$i], 'uploads/'.$filename);
            }
        }
    }
}